import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Language } from "../../../../extend/language/Language";
import { GBox } from "../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { GScrollPane } from "../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { CurTaskItem } from "./CurTaskItem";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
type int = number;
//class CurTaskList
    
    export  class CurTaskList /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._titleTxt = new Object /* flash.text.TextField */();
            this._titleTxt.selectable = false;
            this._titleTxt.defaultTextFormat = new GTextFormat("", 12, GlobalStyle.color2Uint, true);
            this._titleTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._titleTxt.text = Language.getString(20656) + "：";
            this._titleTxt.width = 100;
            this._titleTxt.height = 20;
            addChild(this._titleTxt);
            this._bodySprite = new GBox();
            this._bodySprite.verticalGap = 3;
            this._bodySprite.direction = GBoxDirection.VERTICAL;
            this._scrollPane = new GScrollPane();
            this._scrollPane.width = this._width;
            this._scrollPane.height = this._height - 2;
            this._scrollPane.x = this._titleTxt.x + this._titleTxt.textWidth + 5;
            this._scrollPane.y = 0;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.source = this._bodySprite;
            addChild(this._scrollPane);
            this._line = GlobalClass.getScaleBitmap(ImagesConst.SplitLine);
            this._line.width = this._width;
            this._line.y = this._height - 2;
            addChild(this._line);
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            this.dispose();
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                if ((loc3 = arg1[loc1]) != null) 
                {
                    (loc4 = ObjectPool.getObject(CurTaskItem)).updateData(loc3);
                    this._bodySprite.addChild(loc4);
                }
                ++loc1;
            }
            this._bodySprite.invalidate();
            this._scrollPane.update();
            this._scrollPane.refreshPane();
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._bodySprite.numChildren > 0) 
            {
                loc1 = this._bodySprite.removeChildAt(0) as CurTaskItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1, CurTaskItem);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return this._height;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_titleTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_bodySprite: GBox;

        /* internal */ /* var */_scrollPane: GScrollPane;

        /* internal */ /* var */_line: ScaleBitmap;
    }
